package com.hpin.mlxteacher.my;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;

import com.hpin.mlxteacher.R;
import com.hpin.mlxteacher.base.BaseActivity;
import com.hpin.mlxteacher.utils.CommonUtils;

/**
 * 修改密码页面
 * Created by Aaron on 15/7/31.
 */
public class ChangePswActivity extends BaseActivity {

    private EditText et_old_psw;
    private EditText et_new_psw;
    private EditText et_new_psw_repeat;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_chage_psw);
        initWidget();
    }

    private void initWidget() {

        ImageView tv_left = (ImageView) findViewById(R.id.iv_left);
        TextView tv_title = (TextView) findViewById(R.id.tv_title);
        TextView tv_right = (TextView) findViewById(R.id.tv_right);

        tv_title.setText(getResources().getString(R.string.change_name));
        tv_right.setText(getResources().getString(R.string.done));

        tv_left.setOnClickListener(this);
        tv_right.setOnClickListener(this);

        et_old_psw = (EditText) findViewById(R.id.et_old_psw);
        et_new_psw = (EditText) findViewById(R.id.et_new_psw);
        et_new_psw_repeat = (EditText) findViewById(R.id.et_new_psw_repeat);


    }

    @Override
    public void widgetClick(View v) {
        switch (v.getId()) {
            case R.id.iv_left:
                finish();
                break;
            case R.id.tv_right:

                String oldPsw = et_old_psw.getText().toString().trim();
                String newPsw = et_new_psw.getText().toString().trim();
                String newPswRepeat = et_new_psw_repeat.getText().toString().trim();

                if (CommonUtils.isNull(oldPsw)) {

                    showToast("请输入旧密码");
                    return;
                }
                if (CommonUtils.isNull(newPsw)) {

                    showToast("请输入新密码");
                    return;
                }
                if (!newPsw.equals(newPswRepeat)) {

                    showToast("两次输入的新密码不一致");
                    return;
                }

                break;

        }
    }
}
